package engineer.view.entity_model;

import entity_model.Relationship;
import javafx.scene.control.TableCell;
import javafx.scene.control.Tooltip;
import utils.titles.Title;

/**
 * Created by nuno-rafael-figueiredo on 13-05-2014.
 */
public class RoleTitleTableCell extends TableCell<Relationship.Related, Title> {
    private RequestRole requestRole;

    public RoleTitleTableCell(RequestRole requestRole){
        this.requestRole = requestRole;
    }

    @Override
    protected void updateItem(Title title, boolean empty) {
        super.updateItem(title, empty);
        if (empty) {
            setText(null);
            return;
        }

        setText(title.toString());
        setTooltip(new Tooltip(requestRole.getRole((Relationship.Related) getTableRow().getItem()).getEntity().getName()));
    }
}
